<?php
/**
 * @ClassName: ShopGoodsEnum
 * @Description: 商品枚举
 * @author: gydtrade
 * @Date: 2025-09-26 17:47
 * @Version: V1.0.0
 */

namespace app\common\enum;

class ShopGoodsEnum
{
    //是否参与分账，0否，1是
    const is_divide_yes = 1;
    const is_divide_no = 0;

    //上架状态，0下架，1上架
    const on_sale_yes = 1;
    const on_sale_no = 0;

    //是否显示，0不显示，1显示
    const is_show_yes = 1;
    const is_show_no = 0;

    //是否已分账，0否，1是
    const divide_yes = 1;
    const divide_no = 0;

    //商品类型
    const goods_type_0 = 0;
    const goods_type_1 = 1;
    const goods_type_2 = 2;
    const goods_type_3 = 3;
    const goods_type_4 = 4;
    const goods_type_5 = 5;
    const goods_type_6 = 6;
    const goods_type_7 = 7;

    //积分兑换类型
    const exchange_type_0 = 0;
    const exchange_type_1 = 1;
    const exchange_type_2 = 2;
    const exchange_type_3 = 3;

    /**
     * 是否参与分账，1是，0否
     * @param $level
     * @return string|string[]
     */
    public static function isDivideText($level)
    {
        $desc = [
            ShopGoodsEnum::is_divide_yes => '是',
            ShopGoodsEnum::is_divide_no => '否',
        ];
        if ($level === true) {
            return $desc;
        }
        return $desc[$level] ?? $level;
    }

    /**
     * 上架状态，0下架，1上架
     * @param $level
     * @return string|string[]
     */
    public static function onSaleText($level)
    {
        $desc = [
            ShopGoodsEnum::on_sale_yes => '上架',
            ShopGoodsEnum::on_sale_no => '下架',
        ];
        if ($level === true) {
            return $desc;
        }
        return $desc[$level] ?? $level;
    }

    /**
     * 是否显示，0不显示，1显示
     * @param $level
     * @return string|string[]
     */
    public static function isShowText($level)
    {
        $desc = [
            ShopGoodsEnum::is_show_yes => '显示',
            ShopGoodsEnum::is_show_no => '不显示',
        ];
        if ($level === true) {
            return $desc;
        }
        return $desc[$level] ?? $level;
    }

    /**
     * 是否已分账，1是，0否
     * @param $level
     * @return string|string[]
     */
    public static function divideStatusText($level)
    {
        $desc = [
            ShopGoodsEnum::divide_yes => '是',
            ShopGoodsEnum::divide_no => '否',
        ];
        if ($level === true) {
            return $desc;
        }
        return $desc[$level] ?? $level;
    }

    /**
     * 商品类型
     * @param $level
     * @return string|string[]
     */
    public static function goodsTypeText($level)
    {
        $desc = [
            ShopGoodsEnum::goods_type_0 => '普通商品',
            ShopGoodsEnum::goods_type_1 => '积分商品',
            ShopGoodsEnum::goods_type_2 => '酒店',
            ShopGoodsEnum::goods_type_3 => '门票',
            ShopGoodsEnum::goods_type_4 => '水票',
            ShopGoodsEnum::goods_type_5 => '饮水设备',
            ShopGoodsEnum::goods_type_6 => '水产品',
            ShopGoodsEnum::goods_type_7 => '虚拟商品',
        ];
        if ($level === true) {
            return $desc;
        }
        return $desc[$level] ?? $level;
    }

    /**
     * 积分兑换类型
     * @param $level
     * @return string|string[]
     */
    public static function exchangeTypeText($level)
    {
        $desc = [
            ShopGoodsEnum::exchange_type_0 => '无',
            ShopGoodsEnum::exchange_type_1 => '积分',
            ShopGoodsEnum::exchange_type_2 => '现金',
            ShopGoodsEnum::exchange_type_3 => '积分+现金',
        ];
        if ($level === true) {
            return $desc;
        }
        return $desc[$level] ?? $level;
    }
}